#ifndef DEPOTHANDLER_H
#define DEPOTHANDLER_H

#include <QObject>
#include "db/db.h"
#include "config/config.h"
#include <QStringList>
#include <QList>
#include <QStandardItem>
#include <QSqlDatabase>
#include <QDropEvent>
#include "depot.h"
#include "depotview.h"
#include "global/global.h"

#define USER_DEPOT  1
#define AI_DEPOT    2

#define NO_FLAG 0x00
#define NEW_DEPOT_STOCK 0x01

class DepotHandler:public DepotView,public DB
{
public:
    DepotHandler(QObject* parent=0,QWidget* wParent=0);
    DepotHandler(Config *cfg, QObject *parent=0,QWidget* wParent=0);
    DepotHandler(Stock* s,Config* cfg,QObject* parent=0,QWidget* wParent=0);
    ~DepotHandler();

    void addDepot(const QString& depotName,const QString& liquidity,const QString& standardProvision,int type=USER_DEPOT);
    void addDepot(const QString& depotName,qreal liquidity,qreal standardProvision,int type=USER_DEPOT);

    Depot* getDepot(const QString& depotName)const;
    QStringList getAllDepotNames()const;
    //QStringList getStockNames()const;

    void addStockToDepot(const QString& depotName,const QString& stockName, int flag=NO_FLAG);

    void init();

public slots:
    void viewDepotChanged(int);
    //void changedStandardValue(const QString& depotName,const QString& standardValueField, const QString &value);

private:
    QMap<QString,Depot*> depots;                //values of all depots
    QStringList valSymbols,standardFields;      //names of the values stored in the same order like in list of the map
    Config* cfg;                                //don't delete!
    Stock* tmpStock;                            //don't delete, pointer to the whole stocks, to get all available stock information
    Depot* currentViewedDepot;                  //don't delete, the depot which is current shown
};

#endif // DEPOTHANDLER_H
